﻿@{
    string action = "";
    if (ViewBag.Action != null) {
        action = (string)ViewBag.Action;
    }
    string formAction = "";
    switch (action) {
        case "C":
            formAction = Url.Action("Create");
            break;
        case "U":
            formAction = Url.Action("Update");
            break;
    }
}
<div title="场地人员信息">
    <form id="form1" method="post" action="@formAction">
    @Html.ValidationSummary(true)
    </form>
</div>
<div class="form-bar">
    <input id="btnsubmit" type="button" class="button" name="submit" value="提交" />
</div>
@section footer{
    <script src="@Url.Content("~/Scripts/jquery/jquery.validate.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery/jquery.metadata.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery/messages_cn.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.form.js")" type="text/javascript"></script>
    <script type="text/javascript">
        var id = '@ViewBag.Id';
       
        var action = '@action';
        var fields = [
            { display: "姓名", name: "Contactor", newline: false, labelWidth: 100, width: 220, space: 30, type: "text", group: "客户信息",
                validate: { required: true, maxlength: 50 }
            }
            , { display: "身份证号", name: "Idcard", newline: false, labelWidth: 100, width: 220, space: 30, type: "text",
                validate: { required: true, maxlength: 20 }
            }
            , { display: "性别", name: "Sexs", newline: true, labelWidth: 100, width: 220, space: 30, type: "text",
                validate: { maxlength: 50 }
            }
            , { display: "联系电话", name: "Phone", newline: false, labelWidth: 100, width: 220, space: 30, type: "text",
                validate: { maxlength: 50 }
            }
            , { display: "出生日期", name: "Birthdate", newline: true, labelWidth: 100, width: 220, space: 30, type: "datetime",
                validate: { maxlength: 50 }
            }
            , { display: "年龄", name: " ", newline: false, labelWidth: 100, width: 220, space: 30, type: "text",
                validate: { maxlength: 50 }
            }
            , { display: "工种", name: "Jobsid", newline: true, labelWidth: 100, width: 220, space: 30, type: "text",
                validate: { maxlength: 50 }
            }            
//            , { display: "家庭地址", name: " ", newline: false, labelwidth: 100, width: 220, space: 30, type: "text",
//                validate: { required: true, maxlength: 1 }
//            }
            , { display: "备注", name: "Remarks", newline: true, labelWidth: 100, width: 520, space: 30, type: "textarea",
                validate: { maxlength: 400 }
            }
        ];
            $(function () {
                var form = $("#form1");
                form.ligerForm({ inputWidth: 280, fields: fields });
                if (action != "C") {
                    LG.loadForm(form, { url: '@Url.Action("Get")' });
                }
                if (action == 'U' || action == 'C') {
                    LG.setFormStatus(form, true, parent);
                } else {
                    LG.setFormStatus(form, false);
                }
            });
    </script>
}

